export default {
  data() {
    return {
      preview: false,
      playing: false,
      timer: null
    }
  },
  computed: {
    previewClass() {
      return this.preview ? 'icon-card--preview' : ''
    }
  },
  methods: {
    toggle(preview: boolean) {
      this.preview = preview
    },
    setPlaying(playing: boolean) {
      this.playing = playing
    },
    start(timeout = 3000) {
      if (this.timer) {
        clearTimeout(this.timer)
        this.timer = null
      }
      this.setPlaying(true)
      this.toggle(true)
      this.timer = setTimeout(() => this.toggle(false), timeout)
    }
  }
}
